﻿using System;
using System.Collections.Generic;
using Character;
using H;
using UnityEngine;

// Token: 0x0200021C RID: 540
public class H_ExpressionData_Male
{
	// Token: 0x06000EB0 RID: 3760 RVA: 0x0005C444 File Offset: 0x0005A644
	public H_ExpressionData_Male(H_Expression_Male owner, TextAsset loadList)
	{
		CustomDataListLoader customDataListLoader = new CustomDataListLoader();
		customDataListLoader.Load(loadList);
		int attributeNo = customDataListLoader.GetAttributeNo("状態");
		int attributeNo2 = customDataListLoader.GetAttributeNo("種類");
		int attributeNo3 = customDataListLoader.GetAttributeNo("目");
		int attributeNo4 = customDataListLoader.GetAttributeNo("口");
		int attributeNo5 = customDataListLoader.GetAttributeNo("目の開き");
		int attributeNo6 = customDataListLoader.GetAttributeNo("口の開き");
		for (int i = 0; i < customDataListLoader.GetDataNum(); i++)
		{
			string data = customDataListLoader.GetData(attributeNo, i);
			string data2 = customDataListLoader.GetData(attributeNo2, i);
			string text = customDataListLoader.GetData(attributeNo3, i);
			string text2 = customDataListLoader.GetData(attributeNo4, i);
			float eyeOpen = float.Parse(customDataListLoader.GetData(attributeNo5, i));
			float mouthOpen = float.Parse(customDataListLoader.GetData(attributeNo6, i));
			text = owner.EyeName(text);
			text2 = owner.MouthName(text2);
			this.CreateTypeData(data, data2, text, text2, eyeOpen, mouthOpen);
		}
	}

	// Token: 0x06000EB1 RID: 3761 RVA: 0x0005C54C File Offset: 0x0005A74C
	private void CreateTypeData(string state, string type, string eyeType, string mouthType, float eyeOpen, float mouthOpen)
	{
		string[] array = state.Split(new char[]
		{
			','
		});
		for (int i = 0; i < array.Length; i++)
		{
			this.datas.Add(new H_ExpressionData_Male.Data(array[i], type, eyeType, mouthType, eyeOpen, mouthOpen));
		}
	}

	// Token: 0x06000EB2 RID: 3762 RVA: 0x0005C59C File Offset: 0x0005A79C
	public H_ExpressionData_Male.Data ChangeExpression(Male male, H_Expression_Male.TYPE type, H_Parameter param, float duration)
	{
		H_ExpressionData_Male.Data data = null;
		List<H_ExpressionData_Male.Data> list = new List<H_ExpressionData_Male.Data>();
		H_Expression_Male.STATE state = H_Expression_Male.STATE.NORMAL;
		if (male.MaleID == MALE_ID.KOUICHI)
		{
			state = H_Expression_Male.STATE.HATE;
		}
		foreach (H_ExpressionData_Male.Data data2 in this.datas)
		{
			if (data2.state == state && data2.type == type)
			{
				list.Add(data2);
			}
		}
		if (list.Count > 0)
		{
			int index = UnityEngine.Random.Range(0, list.Count);
			data = list[index];
		}
		if (data != null)
		{
			male.ExpressionPlay(0, data.eyeType, duration);
			male.blink.LimitMax = data.eyeOpen * 0.01f;
			male.lipSync.RelaxOpen = data.mouthOpen * 0.01f;
			bool flag = param.UseMouth(SEX.MALE);
			string name = H_ExpressionData_Male.MouthNo(male, data, param);
			male.ExpressionPlay(1, name, duration);
			male.lipSync.Hold = (flag || male.Gag);
			male.head.ResetMouth(flag || male.Gag);
			TONGUE_TYPE tongueType = (!flag) ? TONGUE_TYPE.FACE : TONGUE_TYPE.BODY;
			male.SetTongueType(tongueType);
			male.CheckShow();
		}
		else
		{
			GlobalData.Debug_LogError("没有合适的表情:" + state);
		}
		return data;
	}

	// Token: 0x06000EB3 RID: 3763 RVA: 0x0005C71C File Offset: 0x0005A91C
	private static string MouthNo(Human human, H_ExpressionData_Male.Data data, H_Parameter param)
	{
		if (!param.UseMouth(human.sex))
		{
			return data.mouthType;
		}
		if (param.mouth == H_MOUTH.KISS)
		{
			return "Mouth_Kiss";
		}
		if (param.mouth == H_MOUTH.LICK)
		{
			return "Mouth_Name";
		}
		return data.mouthType;
	}

	// Token: 0x04000F58 RID: 3928
	private static readonly string[] StateStrs = new string[]
	{
		"普通",
		"嫌がり"
	};

	// Token: 0x04000F59 RID: 3929
	private static readonly H_Expression_Male.STATE[] States = new H_Expression_Male.STATE[]
	{
		H_Expression_Male.STATE.NORMAL,
		H_Expression_Male.STATE.HATE
	};

	// Token: 0x04000F5A RID: 3930
	private static readonly string[] TypeStrs = new string[]
	{
		"通常",
		"射精"
	};

	// Token: 0x04000F5B RID: 3931
	private List<H_ExpressionData_Male.Data> datas = new List<H_ExpressionData_Male.Data>();

	// Token: 0x0200021D RID: 541
	public class Data
	{
		// Token: 0x06000EB5 RID: 3765 RVA: 0x0005C7C0 File Offset: 0x0005A9C0
		public Data(string state, string type, string eyeType, string mouthType, float eyeOpen, float mouthOpen)
		{
			this.state = H_ExpressionData_Male.Data.CheckState(state);
			this.type = H_ExpressionData_Male.Data.CheckType(type);
			this.eyeType = eyeType;
			this.mouthType = mouthType;
			this.eyeOpen = eyeOpen;
			this.mouthOpen = mouthOpen;
		}

		// Token: 0x06000EB6 RID: 3766 RVA: 0x0005C800 File Offset: 0x0005AA00
		private static H_Expression_Male.STATE CheckState(string str)
		{
			H_Expression_Male.STATE result = H_Expression_Male.STATE.NORMAL;
			int i;
			for (i = 0; i < H_ExpressionData_Male.StateStrs.Length; i++)
			{
				if (str == H_ExpressionData_Male.StateStrs[i])
				{
					result = H_ExpressionData_Male.States[i];
					break;
				}
			}
			if (i == H_ExpressionData_Male.StateStrs.Length)
			{
				GlobalData.Debug_LogError("不明状态:" + str);
			}
			return result;
		}

		// Token: 0x06000EB7 RID: 3767 RVA: 0x0005C864 File Offset: 0x0005AA64
		private static H_Expression_Male.TYPE CheckType(string str)
		{
			for (int i = 0; i < H_ExpressionData_Male.TypeStrs.Length; i++)
			{
				if (str == H_ExpressionData_Male.TypeStrs[i])
				{
					return (H_Expression_Male.TYPE)i;
				}
			}
			GlobalData.Debug_LogError("不明种类:" + str);
			return H_Expression_Male.TYPE.NUM;
		}

		// Token: 0x04000F5C RID: 3932
		public string eyeType;

		// Token: 0x04000F5D RID: 3933
		public string mouthType;

		// Token: 0x04000F5E RID: 3934
		public float eyeOpen;

		// Token: 0x04000F5F RID: 3935
		public float mouthOpen;

		// Token: 0x04000F60 RID: 3936
		public H_Expression_Male.STATE state;

		// Token: 0x04000F61 RID: 3937
		public H_Expression_Male.TYPE type;
	}
}
